Socket
Socket
Sign inDemoInstall

@poppinss/profiler

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@poppinss/profiler

Profiler to time function calls in AdonisJs with context


Version published
Weekly downloads
7
increased by16.67%
Maintainers
1
Weekly downloads
 
Created
Source

Profiler

Profiler to time actions in your code with context.

circleci-image npm-image license-image

Profiler is a tiny library to time functions in your Node.js code with context, so that you can present related actions after they have been completed.

Table of contents

Usage

Install the package from the npm registry as follows:

npm i @adonisjs/profiler

# yarn
yarn add @adonisjs/profiler

and then use it as follows

import { Profiler } from '@adonisjs/profiler/build/standalone'

const profiler = new Profiler({
  enabled: true,
  whitelist: [],
  blacklist: [],
})

Usage with AdonisJs

The @adonisjs/core module includes this module by default. However, here's how you can set it up manually.

const providers = [
  '@adonisjs/profiler/build/providers/ProfilerProvider'
]

And then also register the typings file inside tsconfig.json file.

{
  "files": ["./node_modules/@adonisjs/profiler/build/adonis-typings/profiler.d.ts"]
}

You will need only one instance of the profiler in your entire application and then you will work with rows and actions to time function calls.

Subscriber

The profiling data is delivered to a subscriber function and then subscriber can decide the storage or representation of data.

profiler.subscribe((packet) => {
  // write somewhere
})

You can only have one subscriber listening for profiler packets at a given time. This is done for the simplicitiy and performance, since we want the profiler to have minimum overhead to your applications.

White/blacklisting

The scope of profiling should always trim down as your application get mature, in that scanerio, instead of removing profiler calls, you can blacklist or whitelist actions and they will result in noop. For example:

const profiler = new Profiler({
  enabled: true,
  whitelist: [],
  blacklist: ['find:route'],
})

const row = profile.create('http:request', { url: '/' })
row.profile('find:route', {}, () => {
  // Code to find route
})

Without changing anything in your code, the find:route action will have no impact. If you will blacklist a row label, then all of it's actions will be disabled as well.

API Docs

Following are the autogenerated files via Typedoc

Maintainers

Harminder virk

Keywords

FAQs

Package last updated on 06 Sep 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc